package com.spaceobj.chess.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.spaceobj.chess.entity.GameChatInfo;
import com.spaceobj.chess.service.MySQLService;

@RestController
@RequestMapping("/api/chat")
public class GameChatInfoController {

    @Autowired
    private MySQLService mysqlService;

    @PostMapping
    public GameChatInfo save(@RequestBody GameChatInfo chat) {
        mysqlService.saveChat(chat);
        return chat;
    }

    @GetMapping("/{gameId}")
    public List<GameChatInfo> getGameChats(@PathVariable Integer gameId) {
        return mysqlService.getGameChats(gameId);
    }
} 